package com.mybatis.mapper;

import com.mybatis.entity.SysRole;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import com.mybatis.entity.Country;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.Reader;
import java.util.List;


public class RoleMapperTest extends BaseMapperTest{
    private static SqlSessionFactory sqlSessionFactory;


    @Test
    public  void testSelectById(){
        SqlSession sqlSession = getSqlSession();
        try {
            RoleMapper roleMapper = sqlSession.getMapper(RoleMapper.class);
            SysRole role = roleMapper.selectById(1L);
            assert role != null;
            assert "管理员".equals(role.getRoleName());
        }finally {
            sqlSession.close();
        }
    }

    @Test
    public  void testSelectById2(){
        SqlSession sqlSession = getSqlSession();
        try {
            RoleMapper roleMapper = sqlSession.getMapper(RoleMapper.class);
            SysRole role = roleMapper.selectById2(1L);
            assert role != null;
            assert "管理员".equals(role.getRoleName());
        }finally {
            sqlSession.close();
        }
    }

    @Test
    public  void testSelectAll(){
        SqlSession sqlSession = getSqlSession();
        try {
            RoleMapper roleMapper = sqlSession.getMapper(RoleMapper.class);
            // SysRole role = roleMapper.selectById2(1L);
            List<SysRole> roleList = roleMapper.selectAll();
            assert roleList.size() > 0 ;
            assert roleList.get(0).getRoleName() != null;
        }finally {
            sqlSession.close();
        }
    }
}
